//
//  SongListDetailTableViewCell.m
//  YHYRealx
//
//  Created by yanghuiyan on 16/5/4.
//  Copyright © 2016年 yanghuiyan. All rights reserved.
//

#import "SongListDetailTableViewCell.h"

@implementation SongListDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatView];
    }
    return self;
    
}

- (void)creatView {
    
    self.headImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
    
    self.headImageView.layer.masksToBounds = YES;
    //    然后再给图层添加一个有色的边框
    self.headImageView.layer.borderWidth = 3;
    self.headImageView.layer.borderColor = [[UIColor colorWithRed:0.902 green:0.902 blue:0.902 alpha:1.0] CGColor];
    
    self.nameLabel = [[YHYBaseLabel alloc] initWithFrame:CGRectZero];
    
    self.singerLabel = [[YHYBaseLabel alloc] initWithFrame:CGRectZero];
    self.singerLabel.font = [UIFont systemFontOfSize:14];
    self.singerLabel.textColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0];
    
    
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.headImageView];
    [self.contentView addSubview:self.singerLabel];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    
    self.headImageView.frame = CGRectMake(5, 5, self.bounds.size.height - 10, self.bounds.size.height - 10);
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.cornerRadius = (self.bounds.size.height - 10) / 2;
    
    self.nameLabel.frame = CGRectMake(_headImageView.frame.size.width + _headImageView.frame.origin.x + 15, 5, INWIDTH / 2, self.bounds.size.height / 2 - 5);
    
    self.singerLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 5, INWIDTH / 2, self.bounds.size.height / 2 - 5);
    
}

-(void)setSongListDetailModel:(RankListSongListSongsModel *)songListDetailModel {
    
    if (_songListDetailModel != songListDetailModel) {
        [_songListDetailModel release];
        _songListDetailModel = [songListDetailModel retain];
    }
    if (self.songListDetailModel.mvList.count == 0) {
        //        [self.mvButton removeFromSuperview];
    }
    if (self.songListDetailModel.urlList.count == 0) {
        self.singerLabel.textColor = [UIColor colorWithRed:0.702 green:0.702 blue:0.702 alpha:1.0];
    }
    self.nameLabel.text = self.songListDetailModel.name;
    if (self.songListDetailModel.favorites) {
        self.singerLabel.text = [NSString stringWithFormat:@"%@💗%@", self.songListDetailModel.singerName, self.songListDetailModel.favorites];
    } else {
        self.singerLabel.text = self.songListDetailModel.singerName;
    }
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:self.songListDetailModel.picUrl] placeholderImage:[UIImage imageNamed:@"音乐听"]];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
